<?php if($this->errMsg) :?>
	<?php $this->showError($this->errMsg)?>
<?php endif; print_r($this->arrtypenews);?>

<div class="mydiv">
<form name='form' id='form' action="" method="POST">
	<div class="title_ad"><label><a href="">Danh sách câu hỏi</a></label>
	</div>
</form>
	<table  class="display" id="list">
	<thead>
		<tr>
			<th>ID</th>
			<th>qtitle</th>
			<th>Answer/Count</th>
			<th>News</th>
			<th width="90px">qdate</th>
			<th width="40px">Tool</th>
		</tr>
	</thead>
	<tbody>
	<?php
		foreach($this->arrquest as $key=>$row)
		{ 
			echo("<tr>");
				echo("<td>$row->qid</td>");
				echo("<td>$row->qtitle</td>");
				echo("<td>");
				foreach ($row->answer as $keyanswer=>$answer)
				{
					$coler = "";
					if($keyanswer%2 == 0)
						$coler ='color: gray;';
					echo("<lable style='".$coler."'>".$answer->atitle."</lable><lable  style='float: right;".$coler."'>".$answer->acount."</lable><br/>");
				}
				echo("</td>");
				echo("<td>");
				foreach ($row->news as $keynews=>$news)
				{
					$coler = "";
					if($keynews%2 == 1)
						$coler ='style="color: gray;"';
					echo("<lable ".$coler.">".$news->headLines."</lable><br/>");
				}
				echo("</td>");
				echo("<td>$row->qdate</td>");
				echo('<td><a href="'.$this->baseUrl().'/admin/quest/edit/id/'.$row->qid.'" title="Edit" class="tool-16 edit"></a><br/>
				<a href="javascript:del('.$row->qid.')" title="Delete" class="tool-16 delete"></a></td>');
			echo("</tr>");
		} 	
	?>
	</tbody>
</table>
</div>
<script>
function del(key){
	if(!confirm("Bạn muốn xóa câu hỏi khảo sát này không?"))
		return;
	$.ajax({
		type: "POST",
		url:"<?php echo $this->baseUrl.'/admin/quest/delete'?> ",
		data: "id=" + key,	
		success: function(msg){
			if(msg == '1')
				location.replace("<?php echo $this->baseUrl.'/admin/quest/index'?>");
			else
				alert('Error');
		}
	});
}
</script>